﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <%@ include file="../common/header.jsp" %>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <%@ include file="../common/top.jsp" %>

    <div class="row">
        <div class="col-sm-3">
            <c:set var="menu" value="employee"/>
            <%@ include file="../common/menu.jsp" %>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">员工管理</h1>
                </div>
            </div>
            <form class="form-inline" id="searchForm" action="/employee/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>关键字:</label>
                    <input type="text" class="form-control" name="keyword"
                           value="" placeholder="请输入姓名/邮箱">
                </div>
                
                <button type="submit" class="btn btn-primary">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
                <a href="/employee/input.do" class="btn btn-success">
                    <span class="glyphicon glyphicon-plus"></span> 添加
                </a>                
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>编号</th>
                    <th>名称</th>
                    <th>email</th>
                    <th>年龄</th>
                    <th>操作</th>
                </tr>
                
                <c:forEach var="entity" items="${pageInfo.list}">
					<tr>
						 <td>${entity.id}</td>
						 <td>${entity.name}</td>
						 <td>${entity.email}</td>
						 <td>${entity.age}</td>
						 <td>
							 <a href="/employee/input.do?id=${entity.id}" class="btn btn-info btn-xs">
								 <span class="glyphicon glyphicon-pencil"></span> 编辑
							 </a>						 
							 <a data-url="/employee/delete.do?id=${entity.id}"
								class="btn btn-danger btn-xs deleteBtn">
								 <span class="glyphicon glyphicon-trash"></span> 删除
							 </a>
						 </td>
					 </tr>
				</c:forEach>	
				 
            </table>

            <%@ include file="../common/page.jsp" %>
        </div>
    </div>
</div>
<script>
    $(function () {
        //删除按钮绑定点击事件
        $(".deleteBtn").click(function () {
            var url = $(this).data("url");
            $.messager.confirm("温馨提示", "确定要删除吗？", function () {
                $.get(url, function (data) {
                	console.log(data);
                	alert(data);
                    doSuccess();
                });
            }, "json");
        });
        
    });
</script>
</body>
</html>